
package com.itheima.consumer.config;
//可以通过springboot自动注入自动装配
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
public class RestTemplateConfig {
    @Bean
    @LoadBalanced   //进化成ribbon的客户端
    // java.lang.IllegalStateException: No instances available for localhost
    //之后再进行访问http://localhost:8001/goods/findId/1 localhost他会找eureka对应的名字肯定找不到
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }
}
